#include "../inc/ClientPub.hpp"
#include <format>
#include <zmq.hpp>

ClientPub::ClientPub(int port)
    : context(), publisher(context, zmq::socket_type::pub) {
  publisher.bind(std::format("tcp://0.0.0.0:{}", port));
}

void ClientPub::Message(const std::string &msg) {
  publisher.send(zmq::str_buffer("Message"), zmq::send_flags::sndmore);
  publisher.send(zmq::buffer(msg));
}

void ClientPub::CameraOffline(const std::string &UUID) {
  publisher.send(zmq::str_buffer("CameraOffline"), zmq::send_flags::sndmore);
  publisher.send(zmq::buffer(UUID));
}

void ClientPub::StartShot(const std::string &UUID) {
  publisher.send(zmq::str_buffer("StartShot"), zmq::send_flags::sndmore);
  publisher.send(zmq::buffer(UUID));
}

void ClientPub::StopShot(const std::string &UUID) {
  publisher.send(zmq::str_buffer("StopShot"), zmq::send_flags::sndmore);
  publisher.send(zmq::buffer(UUID));
}
